<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upload Csvs</title>
</head>
<body>
Upload File, One at a time <br /><br />

<?php
//

date_default_timezone_set('Australia/Melbourne');
$dateToday = date("Y_m_d");
$csvsfolder = "./csvs/";
$shopFileName="./settings/shops.txt";
if(!empty($_POST)){  
if(!move_uploaded_file($_FILES['useruploadfile']['tmp_name'],$csvsfolder.$_POST['csvfilename'])) {
	echo "file upload Fail<br />";
	}
}
$fl=fopen($shopFileName,"r");
$contents = fread($fl, filesize($shopFileName));
fclose($fl);
$shopArr = explode(",",$contents);
foreach( $shopArr as $key => $value){
$fileNameCsv = trim($value)."_".$dateToday.".csv";
if(!file_exists($csvsfolder.$fileNameCsv)){
?>	
<form   id="form_al_vic" name="form_al_vic" enctype="multipart/form-data" method="post" action="uploadcsvs.php">
Choose File:<input name="useruploadfile" type="file" />
<input type="text"  name="csvfilename"value="<?php echo $fileNameCsv?>">
<input name="submit" type="submit" value="Upload" />
</form><br />
<br />

<?	
	}
else{
	echo "<br />".$fileNameCsv." Uploaded Already   <a href=\"./csvs/delfile.php?fne={$fileNameCsv}\" target=\"_blank\">Click Here Delete</a><br />";
	
	}	
?>
<?php	
	}
?>

</body>
</html>